# from collections import deque

# 实现五个元素的循环队列
class SqQueue:
    def __init__(self):
        self.maxsize = 6  # 循环队列牺牲一个位置
        self.sqqueue = [] * self.maxsize
        self.front = 0
        self.rear = 0

    def enqueue(self, ele):
        if not self.empty():
            self.sqqueue.append(ele)
            self.rear = (self.rear + 1) % self.maxsize

    def dequeue(self):
        self.sqqueue.pop(0)
        self.front = (self.front + 1) % self.maxsize

    def empty(self):
        if (self.rear + 1) % self.maxsize == self.front:
            return 1


if __name__ == '__main__':
    sqqueue = SqQueue()
    print(sqqueue.sqqueue)  # []
    sqqueue.enqueue(1)
    sqqueue.enqueue(2)
    sqqueue.enqueue(3)
    sqqueue.enqueue(4)
    sqqueue.enqueue(5)
    print(sqqueue.sqqueue)  # [1, 2, 3, 4, 5]
    sqqueue.dequeue()
    sqqueue.enqueue(6)
    print(sqqueue.sqqueue)  # [2, 3, 4, 5, 6]


# 试验用
# list1 = [] * 2
# print(list1)
# list1.append(1)
# list1.append(2)
# print(list1)
